package com.qian.apiserver.service;

import java.math.BigDecimal;
import com.qian.apiserver.entity.GmProbability;
import com.qian.apiserver.model.Probability;
import org.springframework.beans.factory.annotation.Autowired;
import com.qian.apiserver.dao.ProbabilityDao;
import com.yaowk.service.common.BaseRepository;
import java.lang.String;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;
import com.qian.apiserver.service.IProbabilityService;

public abstract class ProbabilityServiceBase extends BaseServiceImpl<Probability, GmProbability, Integer> implements IProbabilityService {

	@Autowired
	private ProbabilityDao dao;

	@Override protected ProbabilityDao getDao() {
	return dao;
	}

	@Override
	protected Probability entity2model(GmProbability entity) {
		Probability model = null;
		if(isNotEmpty(entity)){
			model = new Probability();
			model.setId(entity.getId());
			model.setType(entity.getType());
			model.setRate(entity.getRate());
		}
		return model;
	}

	@Override
	protected GmProbability model2Entity(Probability model) {
		GmProbability entity = null;
		if(isNotEmpty(model)){
			entity = new GmProbability();
			entity.setId(model.getId());
			entity.setType(model.getType());
			entity.setRate(model.getRate());
		}
		return entity;
	}

	@Override
	protected GmProbability updateParams(Probability model) {
		GmProbability entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getType()))
			entity.setType(model.getType());
		if(isNotEmpty(model.getRate()))
			entity.setRate(model.getRate());
		return entity;
	}


}